package io.renren.modules.doc.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.doc.entity.ChatSessionEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;

@Mapper
public interface ChatSessionDao extends BaseMapper<ChatSessionEntity> {
    
    @Select("SELECT * FROM sys_chat_session WHERE user_id = #{userId} ORDER BY update_time DESC")
    List<ChatSessionEntity> getUserSessions(Long userId);
    
    @Update("UPDATE sys_chat_session SET last_message = #{lastMessage}, update_time = CURRENT_TIMESTAMP WHERE session_id = #{sessionId}")
    void updateLastMessage(String sessionId, String lastMessage);
}
